package com.open.capacity.user.dao;

import com.open.capacity.common.model.SysRole;
import com.open.capacity.common.model.SysUser;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @author cheng
 * @date 2021-02-02 11:20
 */
@Mapper
public interface EducationalAdminDao {
    List<SysUser> findPersons(Map<String, Object> params);

    List<SysUser> findPersonList(Map<String, Object> params);

    @Select("select id,code,name from sys_role where id in(6,7,8)")
    List<SysRole> findRolesNoStudent(Map<String, Object> params);

    @Select("select id,username,nick_name from sys_user where id in (select a.user_id from sys_role_user a where a.role_id=6)")
    List<SysUser> findTeacher(Map<String, Object> params);

    @Insert("insert into student_handmaster(studid,teacid) values (#{username},#{teacherId})")
    void addStu_Teacher(SysUser sysUser);

    @Insert("insert into sys_role_user(user_id,role_id) values (#{id},5)")
    void addRoles(SysUser sysUser);

    int findPersonsCount(Map<String, Object> params);

    @Update("update student_handmaster set teacid=#{teacherId} where studid=#{username}")
    void updateTeacher(SysUser sysUser);
}
